<template>
  <div class="self-msg msg-box">
    <div class="avatar">
      <img :src="source.senderIcon" alt="avatar" v-default-img="maleImg" />
    </div>

    <div class="content common-content">
      <div class="msg">
        <div class="txt">{{ source.content }}</div>
        <div class="msg-btm" :class="{ hasRemark: source.remark }">
          <div class="remark" v-if="source.remark">{{ source.remark }}</div>
          <Time :t="source.msgTime" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import Time from '../time.vue'
import maleImg from '@/assets/img/defaultImg/male.png'

type Props = {
  source: any
}

defineProps<Props>()
</script>

<style lang="less" scoped>
@import url('./common.less');

.self-msg {
  flex-flow: row-reverse;
}

.content {
  margin-right: 9px;
  background-color: rgba(105, 62, 229, 1);

  &::before {
    right: 0;
    top: 10px;
    border-left: 8px solid rgba(105, 62, 229, 1);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    transform: translateX(100%);
  }
}

.msg-btm {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  transform: translate(8px, 4px);

  .remark {
    margin-right: 20px;
    line-height: 1;
    font-size: 12px;
    color: rgba(246, 216, 59, 1);
  }

  &.hasRemark {
    margin-top: 6px;
    transform: translate(0);
    justify-content: space-between;

    :deep(.time) {
      color: #fff;
    }
  }
}

// :deep(.time) {
//   color: rgba(255, 244, 237, 1);
// }
</style>
